//创建web服务器
const http = require("http");
const server = http.createServer();
const fs = require("fs");
const path = require("path");
server.on("request", function (req, res) {
  const url = req.url;
  console.log(url);
  // var fpath = "";
  // if (url === "/") {
  //   fpath = path.join(__dirname, '/index.html');
  // } else {
  //   fpath = path.join(__dirname, url);
  // }

  // fs.readFile(fpath, "utf8", function (err, dataStr) {
  //   if (err) {
  //     return res.end("404 not found");
  //   }
  //   res.end(dataStr);
  // });
});
server.listen(80, function () {
  console.log("server listen at http://127.0.0.1");
});
